﻿@using TomNet.IMSC.Model.DbModels.Organization
@{
	Layout = null;
	var infoStaff = ViewData["staff"] as Staff;
}


<!DOCTYPE html>

<html>
<head>
	<meta name="viewport" content="width=device-width" />
	<link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
	<link href="~/Content/Css/animate.css" rel="stylesheet">
	<link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
	<link href="~/Content/Css/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="~/Content/Common.css" rel="stylesheet" />
	<title>Insert</title>
</head>
<body>
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="col-xs-12">
			<form class="form-horizontal m-t" id="mainForm">
				<input type="hidden" name="StaffId" value="@infoStaff.Id" />
				<div class="form-group">
					<label class="col-xs-3 control-label">姓名：</label>
					<div class="col-xs-9">
						<input type="text" disabled="" placeholder="@infoStaff.Name" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-3 control-label">类型：</label>
					<div class="col-xs-9">
						@Html.DropDownList("LoginType", (SelectList)ViewBag.selectLoginType, new { @class = "form-control m-b" })
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-3 control-label">登录名：</label>
					<div class="col-xs-9">
						<input id="LoginName" name="LoginName" type="text" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-3 control-label">密码：</label>
					<div class="col-xs-9">
						<input id="LoginPass" name="LoginPass" type="text" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-3 control-label">状态：</label>
					<div class="col-xs-9 radio i-checks">
						<input type="radio" id="State_1" name="State" value="1"><i></i><label for="State_1" class="radio-label">正常</label>
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="radio" id="State_0" name="State" value="0" checked="checked"><i></i><label for="State_0" class="radio-label">不可用</label>
					</div>
				</div>
				<div>
					<button id="submit" class="btn btn-primary pull-right" type="submit">
						<i class="fa fa-check"></i>&nbsp;提&nbsp;交
					</button>
				</div>
			</form>
		</div>
	</div>
	<!-- 全局js -->
	<script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
	<script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
	<script type="text/javascript" src="~/Scripts/plugins/iCheck/icheck.min.js"></script>
	<!-- jQuery Validation plugin javascript-->
	<script type="text/javascript" src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
	<script type="text/javascript" src="~/Scripts/plugins/validate/messages_zh.min.js"></script>
	<script type="text/javascript" src="~/Scripts/Extensions/ExtValidator.js"></script>
	<!-- layer javascript -->
	<script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>

	<script>
		$('.i-checks').iCheck({
			radioClass: 'iradio_square-green',
		});

        $(function () {
            // validate signup form on keyup and submit
            var icon = "<i class='fa fa-times-circle'></i> ";
            var validator = $("#mainForm").validate({
            	rules: {
            		LoginType: { required: true },
            		LoginName: { required: true, minlength: 2 },
            		LoginPass: { required: true }
            	},
            	messages: {
            		LoginType: {
            			required: icon + "请选择登录类型"
            		},
            		LoginName: {
            			required: icon + "请输入登录名",
            			minlength: icon + "登录名不少于两个字符"
            		},
            		LoginPass: {
            			required: icon + "请输入密码"
            		}
                },
                submitHandler: function (form) {
                    //进行ajax传值
                    $.ajax({
                        url: "/organization/staff/logininsertasync",
                        type: "post",
                        dataType: "json",
                        data: $('#mainForm').serialize(),
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.type;
                            if (type == 1) {
                                layer.msg(data.content, { icon: 6, time: 2000 },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                    });

                            } else {
                                layer.msg(data.content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }
            });
        });
	</script>
</body>
</html>
